package com.ruoyi.rural.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rural.domain.RuralVaccineAppointment;
import com.ruoyi.rural.service.IRuralVaccineAppointmentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 疫苗预约Controller
 * 
 * @author ruoyi
 * @date 2022-02-06
 */
@RestController
@RequestMapping("/ruralVaccineAppointment")
public class RuralVaccineAppointmentController extends BaseController
{
    @Autowired
    private IRuralVaccineAppointmentService ruralVaccineAppointmentService;

    /**
     * 查询疫苗预约列表
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:list")
    @GetMapping("/list")
    public TableDataInfo list(RuralVaccineAppointment ruralVaccineAppointment)
    {
        startPage();
        List<RuralVaccineAppointment> list = ruralVaccineAppointmentService.selectRuralVaccineAppointmentList(ruralVaccineAppointment);
        return getDataTable(list);
    }

    /**
     * 导出疫苗预约列表
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:export")
    @Log(title = "疫苗预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RuralVaccineAppointment ruralVaccineAppointment)
    {
        List<RuralVaccineAppointment> list = ruralVaccineAppointmentService.selectRuralVaccineAppointmentList(ruralVaccineAppointment);
        ExcelUtil<RuralVaccineAppointment> util = new ExcelUtil<RuralVaccineAppointment>(RuralVaccineAppointment.class);
        util.exportExcel(response, list, "疫苗预约数据");
    }

    /**
     * 获取疫苗预约详细信息
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(ruralVaccineAppointmentService.selectRuralVaccineAppointmentById(id));
    }

    /**
     * 新增疫苗预约
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:add")
    @Log(title = "疫苗预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RuralVaccineAppointment ruralVaccineAppointment)
    {
        return toAjax(ruralVaccineAppointmentService.insertRuralVaccineAppointment(ruralVaccineAppointment));
    }

    /**
     * 修改疫苗预约
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:edit")
    @Log(title = "疫苗预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RuralVaccineAppointment ruralVaccineAppointment)
    {
        return toAjax(ruralVaccineAppointmentService.updateRuralVaccineAppointment(ruralVaccineAppointment));
    }

    /**
     * 删除疫苗预约
     */
    @RequiresPermissions("rural:ruralVaccineAppointment:remove")
    @Log(title = "疫苗预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ruralVaccineAppointmentService.deleteRuralVaccineAppointmentByIds(ids));
    }
}
